home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / misc / fopen1.c < prev    next >
C/C++ Source or Header  |  1996-06-07  |  605b  |  25 lines

  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <string.h>
  4. #include "misc.h"
  5. #include "../userconf/userconf.h"
  6. #include "misc.m"
  7.  
  8. /*
  9.     Open a configuration file and print an error message if it can't be done.
  10.     Check if root access is needed and prompt the user for the root password
  11.     if the program is setuid.
  12. */
  13. FILE *xconf_fopencfg (const char *fname, const char *mode)
  14. {
  15.     int wr_mode = strchr(mode,'w')!=NULL || strchr(mode,'a')!=NULL;;
  16.     FILE *ret = NULL;
  17.     if (!wr_mode || perm_rootaccess(MSG_U(E_UPDATE,"Update %s"),fname)){
  18.         ret = xconf_fopen (fname,mode);
  19.     }else{
  20.         errno = EPERM;
  21.     }
  22.     return ret;
  23. }
  24.  
  25.